package com.controller.ljl;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.service.ljl.billrecordservice;
import com.service.ljl.payplanservice;
import com.service.ljl.payrecordservice;

@Controller
public class payplancontroller {
	@Autowired
	private payplanservice payplanservice;

	@Autowired
	private payrecordservice payrecordservice;

	@Autowired
	private billrecordservice billrecordservice;

	@PostMapping("/payplan_list")
	@ResponseBody
	public Map<Object, Object> findall(@RequestParam("pagesize") int pagesize, @RequestParam("curpage") int currage) {
		return payplanservice.findall(pagesize, currage);
	}

	@PostMapping("/payplan_add")
	@ResponseBody
	public void add(@RequestBody Map map) {
		payplanservice.add(map);
	}

	@PostMapping("/payplan_delete")
	@ResponseBody
	public void delete(@RequestParam("id") Long id) {
		payplanservice.delete(id);
	}

	@PostMapping("/payplan_deletes")
	@ResponseBody
	public void deletes(@RequestBody JSONArray ids) {
		payplanservice.deletes(JSONArray.parseArray(ids.toString(), Long.class));
	}

	@PostMapping("/payrecord_add")
	@ResponseBody
	public void addrecod(@RequestBody Map map) {
		payrecordservice.add(map);
	}

	@PostMapping("/payrecord_list")
	@ResponseBody
	public Map addrecod(@RequestParam("pagesize") int pagesize, @RequestParam("curpage") int currage) {
		return payrecordservice.findall(pagesize, currage);
	}

	@PostMapping("/payrecord_delete")
	@ResponseBody
	public void deleterecord(@RequestParam("id") Long id) {
		payrecordservice.delete(id);
	}

	@PostMapping("/payrecord_deletes")
	@ResponseBody
	public void deleterecords(@RequestBody JSONArray ids) {
		payrecordservice.deletes(JSONObject.parseArray(ids.toString(), Long.class));
	}

	@PostMapping("/billrecord_add")
	@ResponseBody
	public void addbillrecord(@RequestBody Map map) {
		billrecordservice.add(map);
	}

	@PostMapping("/billrecord_list")
	@ResponseBody
	public Map recordlist(@RequestParam("pagesize") int pagesize, @RequestParam("curpage") int currage) {
		return payrecordservice.findallbill(pagesize, currage);
	}
	
	@PostMapping("/billcord_delete")
	@ResponseBody
	public void deletebill(@RequestParam("id") Long id) {
		billrecordservice.delete(id);
	}

	@PostMapping("/billcord_deletes")
	@ResponseBody
	public void deletebills(@RequestBody JSONArray ids) {
		billrecordservice.deletes(JSONObject.parseArray(ids.toString(), Long.class));
	}

}
